package Month5;

import com.sun.security.jgss.GSSUtil;

public class A20250520LeetcodeTest
{
    public static void main(String[] args)
    {
        int[][] coordinates = {{2,1},{4,2},{6,3}};
        System.out.println(checkStraightLine(coordinates));
    }
    public static boolean checkStraightLine(int[][] coordinates) {



        {

            double k;
            int len = coordinates.length;
            double y2_y1 = coordinates[1][1]-coordinates[0][1];
            System.out.println(y2_y1);
            double x2_x1 = coordinates[1][0] - coordinates[0][0];
            System.out.println(x2_x1);
            if(x2_x1 == 0 )
            {
                for(int i = 2 ; i< len ;i++)
                {
                    if(coordinates[i][0] != coordinates[1][0])
                    {
                        return false;
                    }

                }
                return true;

            }
            else{
                k = y2_y1/x2_x1;
            }
            int count = 1;
            for(int i = 2 ; i < len ;i++)
            {
                System.out.println("_________"+count+"_________");
                count++;
                if(coordinates[i][0] - coordinates[i-1][0] == 0 )
                {
                    return false;
                }
                System.out.println();
                System.out.println(coordinates[i][1]-coordinates[i-1][1]);
                System.out.println(coordinates[i][0] - coordinates[i-1][0]);
                System.out.println();
                double kTest = (double)(coordinates[i][1]-coordinates[i-1][1])/(double)(coordinates[i][0] - coordinates[i-1][0]);
                System.out.println(k);
                System.out.println(kTest);
                if(kTest != k)
                {
                    return false;
                }
            }
            return true;
        }

    }
}
